﻿using Ceremony.API.Infrastructure.EntityConfigurations;
using Ceremony.API.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ceremony.API
{
    public class CeremonyContext : DbContext
    {
        public CeremonyContext(DbContextOptions<CeremonyContext> options) : base(options)
        {
        }
        public DbSet<BobingUser> BobingUsers { get; set; }

        public DbSet<BobingPrizeResult> BobingPrizeResults { get; set; }

        public DbSet<BobingPrize> BobingPrizes { get; set; }
        public DbSet<Authorize> Authorizes { get; set; }
       
        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.ApplyConfiguration(new AuthorizeEntityTypeConfiguration());
            builder.ApplyConfiguration(new BobingUserEntityTypeConfiguration()); 
            builder.ApplyConfiguration(new BobingPrizeResultEntityTypeConfiguration());
            builder.ApplyConfiguration(new BobingPrizeEntityTypeConfiguration());
        }
    }
    public class CeremonyContextDesignFactory : IDesignTimeDbContextFactory<CeremonyContext>
    {
        public CeremonyContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder<CeremonyContext>()
                .UseSqlServer("Server=.;Initial Catalog=CeremonyDb;Integrated Security=true");

            return new CeremonyContext(optionsBuilder.Options);
        }
    }
}
